<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<#import "/common/page.ftl" as p>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${this[0].getText("project_name")}</title>
<link type="text/css" href="${base}/static/css/style.css" rel="stylesheet" rev="stylesheet" />
<link rel="stylesheet" type="text/css" href="${base}/static/js/validate/css/screen.css" />
<link rel="stylesheet" type="text/css" href="${base}/static/js/ext/resources/css/tree.css" />

<script type="text/javascript" src="${base}/static/js/jquery.js"></script>
<script type="text/javascript" src="${base}/static/js/validate/validate.js"></script>
<script type="text/javascript" src="${base}/static/js/validate/cmxforms.js"></script>
<script type="text/javascript" src="${base}/static/js/ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="${base}/static/js/ext/ext-all.js"></script>
<script type="text/javascript">
	function checkSubmit(){
		return false;
	}
	var treedata = ${citydatas};
	
	Ext.BLANK_IMAGE_URL = '${base}/static/js/ext/resources/images/default/s.gif';
	Ext.onReady(function(){
	    // shorthand
	    var Tree = Ext.tree;
	    
	    var tree = new Tree.TreePanel({
	        el:'tree-div',
	        useArrows:false,
	        autoScroll:true,
	        animate:false,
	        enableDD:false,
	        containerScroll: true, 
	        loader: new Tree.TreeLoader({
				preloadChildren: true,
				clearOnLoad: false
			})
	    });
	
	    // set the root node
	    var root = new Tree.AsyncTreeNode({
	        text: '四川省',
	        draggable:false,
			expanded:true,
	        id:'0',
			children:treedata
	    });
	    tree.setRootNode(root);
	
	    // render the tree
	    tree.render();
	    root.expand(true);
		
		tree.on('click', function(node){
		if(node.id!='0'){	
			  $("#zuzhishow")[0].innerHTML = node.text;
			  $("#cityid")[0].value = node.id;
			}
		});
		
		
	});

</script>
</head>
<body>

<div class="main_content">

<br/>
<h2>新增用户</h2>
<#if errorMessage??><font color="red">${this[0].getText(errorMessage)}</font></#if>
<form id="form1" action='${base}/user/insert' method='post'>
	<input type="hidden" id="cityid" name="user.city.id"/>
	<input type="hidden"  name="user.name" value="no_x"/>
	<table style="width:80%">
		 <tr>
			   <td width="40%" id="zuzhitree">
			      <div id="tree-div" style="overflow:auto; height:400px;width:200px;border:1px solid #c3daf9;margin:5px 15px;"></div>
			   <td> 
		 	   <td width="60%">      
					 <table cellspacing="0" class="datalist" style="width:100%">
				    	<tr>
							<th width='40%'>真实姓名(企业名称)：</th>
				    		<td width='60%'><input type="text" id="username" name="user.realname"/></td>
				    	</tr>  
						<tr>
							<th>组织机构：</th>
				    		<td id="zuzhishow">&nbsp;</td>
				    	</tr> 	
				    	<tr>
							<th>密码：</th>
				    		<td><input type="password" id="password" name="user.password"/></td>
				    	</tr>
						<tr>
							<th>重复密码：</th>
				    		<td><input type="password" id="confirm_password" name="confirm_password"/></td>
				    	</tr>
						<tr>
				    		<td colspan="2"><input type="submit" value="提交"/></td>
				    	</tr>
				    </table>  
	           </td>
	    </tr>
	</table>
			   	

</form>
</div>
<script type="text/javascript">
$(document).ready(function() {
	$("#form1").validate({
		rules: {     
			"user.name": {
				required: true,
				minlength: 2,
				maxlength:20
			},
			"user.password": {
				required: true,
				minlength: 6
			},
			confirm_password: {
				required: true,
				equalTo: "#password"
			}
       },
	   
	   messages:{
		"user.name": {
			    required: "请填写用户名",
				minlength: "用户名最少为3个字符",
				maxlength:"用户名最多为20个字符"
			},
		"user.password": {
			    required: "请输入密码",
				minlength:"密码最少为6位"
			},
		 confirm_password: {
			    required: "请再次输入密码",
				equalTo:  "两次密码输入不一致"
			}
		}    
	});	
	
});

</script>
</body>
</html>
